package me.caofeng.enums;

/**
 * Copyright © 2017曹峰. All rights reserved.
 *
 * @Prject: mall
 * @Package: me.caofeng.enums
 * @Description:
 * @Author: 曹峰 blog.caofeng.me
 * @Date: 2017-06-16 11:20
 * @Version: V1.0
 */
public enum ResponseCode {
    SUCCESS(0, "SUCCESS"),
    ERROR(1, "ERROR"),
    ILLEGAL_ARGUMENT(2, "ILLEGAL ARGUMENT"),
    FORBIDDEN(3,"FORBIDDEN"),
    UNKNOWN(-1, "UNKNOWN"),
    EMPTY(4,"EMPTY DATA ");
    private int code;
    private String message;

    ResponseCode() {
    }

    ResponseCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static ResponseCode getResonseCode(int code) {
        switch (code) {
            case 0:
                return SUCCESS;
            case 1:
                return ERROR;
            case 2:
                return ILLEGAL_ARGUMENT;
            case 3:
                return FORBIDDEN;
            case 4:
                return EMPTY;
            default:
                return UNKNOWN;
        }
    }
}
